package com.ruoyi.domain.tools;

import com.ruoyi.domain.IdWorker;

import java.util.Random;

public class SuiJiId {
    private long detailOrderIdSJ;//详情订单主键保证唯一随机数
    private long orderIdSJ;//订单主键保证唯一随机数

    public long getDetailOrderIdSJ() {
        return detailOrderIdSJ;
    }

    public void setDetailOrderIdSJ(long detailOrderIdSJ) {
        this.detailOrderIdSJ = detailOrderIdSJ;
    }

    public long getOrderIdSJ() {
        return orderIdSJ;
    }

    public void setOrderIdSJ(long orderIdSJ) {
        this.orderIdSJ = orderIdSJ;
    }

    public SuiJiId() {
        Random rand = new Random();
        this.detailOrderIdSJ = rand.nextInt(1000-100+1)+100;
        this.orderIdSJ = rand.nextInt(10000-1000+1)+1000;
    }
    public long getDetailOrderId(){
        IdWorker idWorker = new IdWorker(1,1,1);
        long detailOrderId = idWorker.nextId();
        String d = detailOrderId+"";
        detailOrderId = Long.parseLong(d.substring(0,16))+this.detailOrderIdSJ;
        return detailOrderId;
    }

    public long getOrderId(){
        IdWorker idWorker = new IdWorker(1,1,1);
        long orderId = idWorker.nextId();
        String o = orderId+"";
        orderId = Long.parseLong(o.substring(0,16))+this.orderIdSJ;
        return orderId;
    }
}
